//
// Created by francklinson on 2021/11/28 AT 15:30.
// May Saint Diana bless you!
//

#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Solution {
public:
    vector<int> monthAccu{0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};

    int dayOfYear(string date) {
        int year = stoi(date.substr(0, 4));
        int month = stoi(date.substr(5, 2));
        int day = stoi(date.substr(8, 2));
        int ans = 0;
        ans = monthAccu[month] + day; // 到这个月之前的月份累计了几天
        return (year % 4 == 0 && month >= 3) ? ans + 1 : ans; // 闰年
    }
};

int main() {
    Solution solution;
    cout << solution.dayOfYear("2019-01-09") << endl;
    cout << solution.dayOfYear("2019-02-10") << endl;
    cout << solution.dayOfYear("2003-03-01") << endl;
    cout << solution.dayOfYear("2004-03-01") << endl;
    cout << solution.dayOfYear("2021-11-28") << endl;
    return 0;
}

